"""添加任务页面"""
from selenium.webdriver.common.by  import By
from page.base_page import BasePage

class AddTaskPage(BasePage):
    url="/crm5/index.php?m=task&a=add"
    subject_locator = (By.CSS_SELECTOR, "#subject")#主题输入框
    owner_name_locator = (By.ID, "owner_name")#负责人选择框
    role_locator = (By.NAME, "to_role_id[]")#负责人名字
    btn_ok_locator = (By.CSS_SELECTOR, "body > div:nth-child(12) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1) > span")
    select1_locator = (By.ID, "select1")#选择相关
    module_name_locator = (By.ID, "module_name")#选择相关后的输入框
    product_id_locator = (By.NAME, "product_id")#产品选择
    btn_yes_locator = (By.XPATH, "/html/body/div[13]/div[3]/div/button[1]/span")
    status_locator = (By.CSS_SELECTOR, "body > div.container > div.row-fluid > div > form > table > tbody > tr:nth-child(6) > td:nth-child(2) > select")
    due_data_text_locator=(By.CSS_SELECTOR,"body > div.container > div.row-fluid > div > form > table > tbody > tr:nth-child(5) > td:nth-child(3)")
    btn_priority_locator = (By.CSS_SELECTOR,"body > div.container > div.row-fluid > div > form > table > tbody > tr:nth-child(6) > td:nth-child(4) > select")
    due_date_locator = (By.ID, "due_date")
    btn_save_locator = (By.CSS_SELECTOR,"body > div.container > div.row-fluid > div > form > table > tfoot > tr > td:nth-child(2) > input:nth-child(1)")
    def input_subject(self,subject):
        self.driver.find_element(*self.subject_locator).send_keys(subject)
    def click_owner(self):
        self.driver.find_element(*self.owner_name_locator).click()
    def role_name(self):
        return self.driver.find_elements(*self.role_locator)
    def click_btn(self):
        self.driver.find_element(*self.btn_ok_locator).click()
    def select_select1(self):
        return self.driver.find_element(*self.select1_locator)
    def click_module(self):
        self.driver.find_element(*self.module_name_locator).click()
    def select_proudct(self):
        return self.driver.find_elements(*self.product_id_locator)
    def click_yes(self):
        self.driver.find_element(*self.btn_yes_locator).click()
    def select_status(self):
        return self.driver.find_element(*self.status_locator)
    def click_save(self):
        self.driver.find_element(*self.btn_save_locator).click()
    def due_date(self,data):
        self.driver.find_element(*self.due_date_locator).send_keys(data)
    def click_due(self):
        self.driver.find_element(*self.due_data_text_locator).click()
    def select_priotity(self):
        return self.driver.find_element(*self.btn_priority_locator)